package cn.hanfeng.taskservice.service;

import cn.hanfeng.taskservice.config.MyScheduledTaskRegistrar;
import cn.hanfeng.taskservice.runnable.SchedulingRunnable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author hanfeng 2020/8/27 15:58
 * @version 0.0.1
 */
@Service
public class TaskAdminService {
    @Autowired
    private MyScheduledTaskRegistrar myScheduledTaskRegistrar;

    public void addCronTask(SchedulingRunnable schedulingRunnable, String cron) {
        myScheduledTaskRegistrar.addCronTask(schedulingRunnable, cron);
    }

    public void editCronTask(SchedulingRunnable schedulingRunnable, String cron) {
        myScheduledTaskRegistrar.editCronTask(schedulingRunnable, cron);
    }

    public void delCronTask(String taskSign) {
        myScheduledTaskRegistrar.removeCronTask(taskSign);
    }
}
